package co.fitstart.weapp.api.service.impl;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.demo2do.core.persistence.annotation.Dao;

import co.fitstart.entity.courseware.fitnessgroup.FitnessGroup;
import co.fitstart.entity.courseware.fitnessgroup.FitnessGroupType;
import co.fitstart.entity.courseware.movement.Movement;
import co.fitstart.weapp.api.dao.FitnessGroupDao;
import co.fitstart.weapp.api.dao.MovementDao;
import co.fitstart.weapp.api.service.MovementService;

/**
 * 
 * @author haiyan_xiao
 *
 */
@Service("movementService")
public class MovementServiceImpl implements MovementService {

    @Dao
    private MovementDao movementDao;

    @Dao
    private FitnessGroupDao fitnessGroupDao;

    /*
     * (non-Javadoc)
     * @see co.fitstart.weapp.api.service.MovementService#list(java.lang.String)
     */
    public List<Movement> list(String name) {
        if(StringUtils.isBlank(name)) {
            return movementDao.list();
        } else {
            return movementDao.list("%" + name.trim() + "%");
        }
    }

    /*
     * (non-Javadoc)
     * @see co.fitstart.weapp.api.service.MovementService#listGroup()
     */
    public List<FitnessGroup> listGroup() {
        return fitnessGroupDao.list(FitnessGroupType.SPECIALTY_COURSE_GROUP);
    }

}
